<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>用户管理 - 相机销售管理系统</title>
  <script src="https://cdn.tailwindcss.com"></script>
  <link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
  <link href="/css/style.css" rel="stylesheet">
  <script src="/js/common.js"></script>
  <script src="/js/customer.js"></script>
</head>
<body class="bg-gray-100 min-h-screen flex flex-col">
<!-- 导航栏 -->
<nav class="bg-gray-800 text-white">
  <div class="container mx-auto px-4 py-3 flex justify-between items-center">
    <div class="flex items-center space-x-2">
      <i class="fa fa-camera-retro text-2xl"></i>
      <span class="text-xl font-bold">相机销售管理系统</span>
    </div>
    <div class="hidden md:flex space-x-6">
      <a href="/" class="hover:text-gray-300 transition-colors duration-200 flex items-center">
        <i class="fa fa-home mr-1"></i> 首页
      </a>
      <a href="/customers" class="bg-gray-700 text-white px-3 py-1 rounded flex items-center">
        <i class="fa fa-users mr-1"></i> 用户管理
      </a>
      <a href="/cameras" class="hover:text-gray-300 transition-colors duration-200 flex items-center">
        <i class="fa fa-camera mr-1"></i> 相机管理
      </a>
      <a href="/cameraTypes" class="hover:text-gray-300 transition-colors duration-200 flex items-center">
        <i class="fa fa-tags mr-1"></i> 相机类型
      </a>
      <a href="/orders" class="hover:text-gray-300 transition-colors duration-200 flex items-center">
        <i class="fa fa-shopping-cart mr-1"></i> 订单管理
      </a>
    </div>
    <div class="md:hidden">
      <button id="menu-toggle" class="focus:outline-none">
        <i class="fa fa-bars text-xl"></i>
      </button>
    </div>
  </div>
  <!-- 移动端菜单 -->
  <div id="mobile-menu" class="hidden md:hidden bg-gray-700 px-4 py-2 space-y-3">
    <a href="/" class="block hover:text-gray-300 transition-colors duration-200">首页</a>
    <a href="/customers" class="block bg-gray-600 text-white px-2 py-1 rounded">用户管理</a>
    <a href="/cameras" class="block hover:text-gray-300 transition-colors duration-200">相机管理</a>
    <a href="/cameraTypes" class="block hover:text-gray-300 transition-colors duration-200">相机类型</a>
    <a href="/orders" class="block hover:text-gray-300 transition-colors duration-200">订单管理</a>
  </div>
</nav>

<!-- 主内容区 -->
<main class="flex-grow container mx-auto px-4 py-6">
  <div class="bg-white rounded-lg shadow p-6 mb-6">
    <div class="flex justify-between items-center mb-6">
      <h2 class="text-2xl font-bold text-gray-800">用户管理</h2>
      <button class="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-lg transition-colors duration-200 flex items-center" onclick="showModal('addCustomerModal')">
        <i class="fa fa-plus mr-2"></i> 添加用户
      </button>
    </div>

    <!-- 搜索框 -->
    <div class="flex flex-col md:flex-row md:items-center justify-between gap-4 mb-6">
      <div class="relative flex-grow max-w-md">
        <input type="text" placeholder="搜索用户..." class="w-full pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-all duration-200">
        <i class="fa fa-search absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400"></i>
      </div>
      <div class="flex space-x-2">
        <button class="bg-white border border-gray-300 hover:bg-gray-100 text-gray-700 px-4 py-2 rounded-lg transition-colors duration-200">
          <i class="fa fa-filter mr-1"></i> 筛选
        </button>
        <button class="bg-white border border-gray-300 hover:bg-gray-100 text-gray-700 px-4 py-2 rounded-lg transition-colors duration-200">
          <i class="fa fa-sort mr-1"></i> 排序
        </button>
      </div>
    </div>

    <!-- 用户表格 -->
    <div class="overflow-x-auto">
      <table class="min-w-full" id="customerTable">
        <thead>
        <tr class="bg-gray-100">
          <th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">ID</th>
          <th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">姓名</th>
          <th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">电话</th>
          <th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">邮箱</th>
          <th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">注册日期</th>
          <th class="px-4 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">操作</th>
        </tr>
        </thead>
        <tbody>
        <tr class="text-center">
          <td colspan="6" class="px-4 py-8 text-gray-500">加载中...</td>
        </tr>
        </tbody>
      </table>
    </div>

    <!-- 分页 -->
    <div class="flex justify-between items-center mt-6">
      <div class="text-sm text-gray-600">
        显示 1-10 条，共 <span id="totalCustomers">0</span> 条
      </div>
      <div class="flex space-x-1">
        <button class="px-3 py-1 rounded border border-gray-300 bg-white text-gray-600 hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed" disabled>
          <i class="fa fa-chevron-left"></i>
        </button>
        <button class="px-3 py-1 rounded border border-gray-300 bg-blue-500 text-white hover:bg-blue-600">1</button>
        <button class="px-3 py-1 rounded border border-gray-300 bg-white text-gray-600 hover:bg-gray-50">2</button>
        <button class="px-3 py-1 rounded border border-gray-300 bg-white text-gray-600 hover:bg-gray-50">3</button>
        <button class="px-3 py-1 rounded border border-gray-300 bg-white text-gray-600 hover:bg-gray-50">
          <i class="fa fa-chevron-right"></i>
        </button>
      </div>
    </div>
  </div>
</main>

<!-- 页脚 -->
<footer class="bg-gray-800 text-white py-6">
  <div class="container mx-auto px-4">
    <div class="flex flex-col md:flex-row justify-between items-center">
      <div class="mb-4 md:mb-0">
        <div class="flex items-center space-x-2">
          <i class="fa fa-camera-retro text-xl"></i>
          <span class="text-lg font-bold">相机销售管理系统</span>
        </div>
        <p class="text-sm text-gray-400 mt-2">专业的相机销售管理解决方案</p>
      </div>
      <div class="flex space-x-6">
        <a href="#" class="text-gray-400 hover:text-white transition-colors duration-200">
          <i class="fa fa-github text-xl"></i>
        </a>
        <a href="#" class="text-gray-400 hover:text-white transition-colors duration-200">
          <i class="fa fa-twitter text-xl"></i>
        </a>
        <a href="#" class="text-gray-400 hover:text-white transition-colors duration-200">
          <i class="fa fa-linkedin text-xl"></i>
        </a>
      </div>
    </div>
    <div class="border-t border-gray-700 mt-6 pt-6 text-center text-sm text-gray-400">
      &copy; 2025 相机销售管理系统. 保留所有权利.
    </div>
  </div>
</footer>

<!-- 添加用户模态框 -->
<div id="addCustomerModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
  <div class="bg-white rounded-lg shadow-xl w-full max-w-md mx-4 transform transition-all duration-300 scale-95 opacity-0" id="addModalContent">
    <div class="p-6">
      <div class="flex justify-between items-center mb-4">
        <h3 class="text-xl font-bold text-gray-800">添加用户</h3>
        <button onclick="hideModal('addCustomerModal')" class="text-gray-500 hover:text-gray-700">
          <i class="fa fa-times"></i>
        </button>
      </div>
      <form id="addCustomerForm">
        <div class="mb-4">
          <label for="name" class="block text-sm font-medium text-gray-700 mb-1">姓名</label>
          <input type="text" id="name" name="name" required class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
        </div>
        <div class="mb-4">
          <label for="phone" class="block text-sm font-medium text-gray-700 mb-1">电话</label>
          <input type="tel" id="phone" name="phone" required class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
        </div>
        <div class="mb-4">
          <label for="email" class="block text-sm font-medium text-gray-700 mb-1">邮箱</label>
          <input type="email" id="email" name="email" required class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
        </div>
        <div class="mb-4">
          <label for="address" class="block text-sm font-medium text-gray-700 mb-1">地址</label>
          <textarea id="address" name="address" rows="3" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"></textarea>
        </div>
        <div class="flex justify-end space-x-3 mt-6">
          <button type="button" onclick="hideModal('addCustomerModal')" class="px-4 py-2 border border-gray-300 rounded-md text-gray-700 hover:bg-gray-50 transition-colors duration-200">取消</button>
          <button type="submit" class="px-4 py-2 bg-blue-500 text-white rounded-md hover:bg-blue-600 transition-colors duration-200">保存</button>
        </div>
      </form>
    </div>
  </div>
</div>

<!-- 编辑用户模态框 -->
<div id="editCustomerModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
  <div class="bg-white rounded-lg shadow-xl w-full max-w-md mx-4 transform transition-all duration-300 scale-95 opacity-0" id="editModalContent">
    <div class="p-6">
      <div class="flex justify-between items-center mb-4">
        <h3 class="text-xl font-bold text-gray-800">编辑用户</h3>
        <button onclick="hideModal('editCustomerModal')" class="text-gray-500 hover:text-gray-700">
          <i class="fa fa-times"></i>
        </button>
      </div>
      <form id="editCustomerForm">
        <input type="hidden" id="editId" name="id">
        <div class="mb-4">
          <label for="editName" class="block text-sm font-medium text-gray-700 mb-1">姓名</label>
          <input type="text" id="editName" name="name" required class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
        </div>
        <div class="mb-4">
          <label for="editPhone" class="block text-sm font-medium text-gray-700 mb-1">电话</label>
          <input type="tel" id="editPhone" name="phone" required class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
        </div>
        <div class="mb-4">
          <label for="editEmail" class="block text-sm font-medium text-gray-700 mb-1">邮箱</label>
          <input type="email" id="editEmail" name="email" required class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
        </div>
        <div class="mb-4">
          <label for="editAddress" class="block text-sm font-medium text-gray-700 mb-1">地址</label>
          <textarea id="editAddress" name="address" rows="3" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"></textarea>
        </div>
        <div class="flex justify-end space-x-3 mt-6">
          <button type="button" onclick="hideModal('editCustomerModal')" class="px-4 py-2 border border-gray-300 rounded-md text-gray-700 hover:bg-gray-50 transition-colors duration-200">取消</button>
          <button type="submit" class="px-4 py-2 bg-blue-500 text-white rounded-md hover:bg-blue-600 transition-colors duration-200">保存</button>
        </div>
      </form>
    </div>
  </div>
</div>

<script>
  // 移动端菜单切换
  document.getElementById('menu-toggle').addEventListener('click', function() {
    const mobileMenu = document.getElementById('mobile-menu');
    mobileMenu.classList.toggle('hidden');
  });

  // 模态框动画效果
  document.addEventListener('DOMContentLoaded', function() {
    // 添加用户模态框动画
    const addModal = document.getElementById('addCustomerModal');
    const addModalContent = document.getElementById('addModalContent');

    addModal.addEventListener('transitionend', function() {
      if (addModal.classList.contains('hidden')) {
        addModalContent.classList.remove('scale-100', 'opacity-100');
        addModalContent.classList.add('scale-95', 'opacity-0');
      }
    });

    // 编辑用户模态框动画
    const editModal = document.getElementById('editCustomerModal');
    const editModalContent = document.getElementById('editModalContent');

    editModal.addEventListener('transitionend', function() {
      if (editModal.classList.contains('hidden')) {
        editModalContent.classList.remove('scale-100', 'opacity-100');
        editModalContent.classList.add('scale-95', 'opacity-0');
      }
    });
  });

  // 显示模态框时添加动画
  function showModal(modalId) {
    const modal = document.getElementById(modalId);
    const modalContent = document.getElementById(modalId.replace('Modal', 'Content'));

    modal.classList.remove('hidden');
    setTimeout(() => {
      modalContent.classList.remove('scale-95', 'opacity-0');
      modalContent.classList.add('scale-100', 'opacity-100');
    }, 10);
  }

  // 隐藏模态框时添加动画
  function hideModal(modalId) {
    const modal = document.getElementById(modalId);
    const modalContent = document.getElementById(modalId.replace('Modal', 'Content'));

    modalContent.classList.remove('scale-100', 'opacity-100');
    modalContent.classList.add('scale-95', 'opacity-0');

    setTimeout(() => {
      modal.classList.add('hidden');
    }, 300);
  }
</script>
</body>
</html>
